import Vue from 'vue'
import vuePlugins from './utils/vuePlugins'
import App from './App'
import router from './router'
import store from './store'
import './less/reset.less'
import './less/common.less'

Vue.use(vuePlugins)
Vue.config.productionTip = false


new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})

router.beforeEach((to, from, next) => {
  if(to.meta.needLogin) {
    let token = localStorage.getItem('token')
    if(token) {
      next()
    } else {
      next({
        path: '/login'
      })
    }
  } else {
    next()
  }
})
